package gui;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Shell;

public class FontLoader {
	
	public static Font loadFont(Shell shell, String fontFileName, int fontSize) {
		boolean isFontLoaded = shell.getDisplay().loadFont(fontFileName);
		if( isFontLoaded ) {  
//			displayAllLoadedFonts(shell);
			return new Font(shell.getDisplay(), "Papyrus", fontSize, SWT.NORMAL);
		}
		return null;
	}

	public static void displayAllLoadedFonts(Shell shell) {
		FontData[] fd = shell.getDisplay().getFontList(null, true);
        for( int i = 0; i < fd.length; i++ ) {
                System.out.println(fd[i].getName());
        }
        // and the non-scalable ones
        fd = shell.getDisplay().getFontList(null, false);
        for( int i = 0; i < fd.length; i++ ) {
                System.out.println(fd[i].getName());
        }	
	}
}
